一、增加redis用户

groupadd redis
useradd redis -g redis -s /sbin/nologin -M

###关闭防火墙###
systemctl stop firewalld    # 关闭服务
systemctl disable firewalld    # 禁止开机启动

systemctl disable NetworkManager.service

二、下载源码包



yum install tcl -y

cd /usr/local/src
wget http://download.redis.io/releases/redis-4.0.10.tar.gz
tar -zxvf redis-4.0.10.tar.gz
cd redis-4.0.10
make test
make MALLOC=libc
make install
#make PREFIX=/usr/local/redis MALLOC=libc install  #安装到指定目录

三、将redis服务设置成启动项

#启动脚本
cp /usr/local/src/redis-4.0.10/utils/redis_init_script /etc/init.d/redis


注意增加了chkconfig和description两行 不然会提示 服务 redisd 不支持 chkconfig









或者

添加开机启动服务
vim /etc/systemd/system/redis-server.service

[Unit]
Description=The redis-server Process Manager
After=syslog.target network.target

[Service]
Type=simple
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/redis/redis-server /usr/local/redis/redis.conf         
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID

[Install]
WantedBy=multi-user.target


设置开机启动

systemctl daemon-reload 
systemctl start redis-server.service 
systemctl enable redis-server.service

Lancger
57 声望2 粉丝